import { queryFinAuditList, queryFinAuditInfo, queryFinAuditCount } from '@/api/finalAccounts/index'
const finalAccounts = {
    state: {
        finalAccountsList: [],//查询列表
        finalAccountsHistotyList: [],//历史记录列表
        searchParams: {},//查询参数
        dicLists: {},
        auditInfo: {},
        total: 0

    },
    mutations: {
        setFinalAccountsList(state, payload) {
            state.finalAccountsList = payload
        },
        setSearchParams(state, payload) {
            state.searchParams = payload
        },
        setFinalAccountsHistotyList(state, payload) {
            state.finalAccountsHistotyList = payload
        },
        setDicLists(state, payload) {
            state.dicLists = payload
        },
        setAuditInfo(state, payload) {
            state.auditInfo = payload
        },
        setCount(state, payload) {
            state.total = payload
        }
    },
    actions: {
        async getSearchList({ commit, state }, pageNum) {
            try {
                const paramsInfo = {
                    ...pageNum,
                    param: {
                        ...state.searchParams
                    }
                }
                const { code, data } = await queryFinAuditList(paramsInfo);
                if (+code === 200) {
                    const result = await queryFinAuditCount(paramsInfo)
                    commit('setCount', result.data)
                    commit('setFinalAccountsList', data)
                }
            } catch (error) {
                console.log(error)
            }
        },
        async getSearchHistoryList({ commit }, params) {
            try {
                const data = []
                commit('setFinalAccountsHistotyList', data)
            } catch (error) {
                console.log(error)
            }
        },
        async getAuditInfo({ commit }, params) {
            try {
                const { data } = await queryFinAuditInfo(params)
                commit('setAuditInfo', data)
            } catch (error) {
                console.log(error)
            }
        },
    },
    getters: {
        getFinalAccountsList(state) {
            return state.finalAccountsList;
        },
        getFinalAccountsHistotyList(state) {
            return state.finalAccountsHistotyList;
        },
        getdicLists(state) {
            return state.dicLists
        },
        getAuditInfo(state) {
            return state.auditInfo
        },
        getCount(state) {
            return state.total
        }
    }
}


export default {
    namespaced: true,
    ...finalAccounts
}
